#include <iostream>

#include "curl/curl.h"
#include "curl/easy.h"

using std::endl, std::cout, std::string;

int main(int argc, char* argv[])
{
    auto curl = curl_easy_init();
    if (curl) {
        cout << "init ok" << endl;
    }
    string url("https://bing.com/index.htm");
    curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
    const char* ca_path = "../cacert.pem";
    curl_easy_setopt(curl, CURLOPT_CAINFO, ca_path);
    curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);

    auto code = curl_easy_perform(curl);
    cout << code << endl;
    cout << curl_easy_strerror(code) << endl;
    if (code == CURLcode::CURLE_OK) {
        int code = 0;
        curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &code);
        cout << code << endl;
    }

    return 0;
}
